Skip to content

fix: admin sign-in applies the same account checks as the regular sign-in - #472

Merged
kikootwo merged 2 commits into
mainfrom
fix/admin-login-account-checks
Oct 27, 2026
Merged

kikootwo merged 2 commits into
mainfrom
fix/admin-login-account-checks

Conversation

@kikootwo

Copy link
Copy Markdown
Owner

What changed

  • POST /api/auth/admin/login (src/app/api/auth/admin/login/route.ts) now checks the account after the password matches and before it records lastLoginAt or issues tokens:
    • pending approval: the same 200 { success: false, pendingApproval: true, message } the regular local sign-in returns, so the login page shows its "Account Pending Approval" notice;
    • rejected: the same 401 { error: 'Account has been rejected' } the regular local sign-in returns;
    • deleted (deletedAt set): the same 401 as an unknown user or a wrong password.
  • New src/lib/services/auth/local-account-status.ts holds the registration check and its two messages. LocalAuthProvider (sign-in and validateAccess) and the local login route now use it too, with no change in what they return.
  • Docs: documentation/backend/services/auth.md (Local Admin Authentication: account checks; one Fixed Issues line).

Why

The admin sign-in now applies the same account checks as the regular sign-in.

Evidence

  • tests/api/auth-admin-login.routes.test.ts, six new route tests: pending, rejected and deleted rows get no tokens, no token calls and no lastLoginAt update, each with the regular sign-in's response; the setup admin (Plex mode, isSetupAdmin), an approved local user and an older row with a null registrationStatus still sign in and get lastLoginAt updated.
  • With main's route and this branch's test file: 3 failed, 9 passed, each on a status or body assertion in the three refused cases. On this branch: 12/12 pass.
  • Rows that sign in today hold approved: the setup wizard writes it for the setup admin in both modes, registration writes it for the first user and whenever approval isn't required, and approving a user sets it. The column defaults to approved, so rows from before it existed got that value. Null is only possible from a manual write; it is treated as approved, as the regular sign-in does.

Checks

  • Unit tests for the changed code (vitest related on the four changed source files, plus the test file): PASS, 6 files, 78/78
  • Type check and lint: PASS (tsc --noEmit clean; ESLint on the 5 touched files reports nothing new compared with main)
  • Image build and smoke (--specs smoke): PASS (image rmab-e2e/t65:07c2e3b, 1/1 smoke spec passed; stack and images removed)
  • After merging main (5f0aa4e): vitest related on the source changed on both sides: PASS, 137 files, 1978/1978; tsc --noEmit clean
  • Full unit suite: PR Tests (CI)

Risk and rollback

  • Who is affected: only accounts that are pending approval, rejected or deleted. Approved accounts, the setup admin and null-status rows sign in as before.
  • rejected is not written by any current path (rejecting a pending user removes the row). Deleted accounts are refused on deletedAt.
  • The checks run after the password, so a wrong password still gets the plain 401 whatever the account's state.
  • The regular local sign-in, OIDC and Plex sign-in are unchanged.
  • Rollback: revert this PR. No data is changed.

Release note

  • Admin sign-in now applies the same account checks as the regular sign-in.

🤖 Generated with Claude Code

kikootwo and others added 2 commits October 27, 2026 02:56
…n-in

The admin sign-in route now refuses accounts pending approval and rejected
accounts with the same responses the regular local sign-in gives, and answers
a deleted account like a wrong password. The registration check is shared
with LocalAuthProvider. The setup admin, approved users and older rows with
no registration status still sign in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kikootwo
kikootwo merged commit 08dc816 into main Oct 27, 2026
1 check passed
@kikootwo
kikootwo deleted the fix/admin-login-account-checks branch October 27, 2026 07:19
@kikootwo kikootwo mentioned this pull request Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant